<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title><!--{if $operFlg == 5}-->添加<!--{else}-->修改<!--{/if}-->文章</title>
    <!--{include file='comm/comm_editor.tpl'}-->
</head>
<body>
<div style="width:100%">

    <div class="items clearfix">

        <h2 style="" class="tal">正在操作：<!--{if $operFlg == 5}-->添加<!--{else}-->修改<!--{/if}-->文章</h2>

        <div class="items2">

            <div>
                <form id="article_form" onsubmit="return false;">
                	<table>
                		<tbody>
                			<tr>
                				<td class="tar" width="150">文章标题：</td>
                				<td width='*'>
				  			 		<input type="hidden" id="article_id" name="article_id" value="<!--{$article_array.article_id|default:0}-->">
				  			 		<input type="text" id="article_title" name="article_title" maxlength="200" size="40" style="ime-mode:active" autocomplete="off" value="<!--{$article_array.article_title|default:''}-->">
				  			 		<font color="red">*</font>
				  			 	</td>
                			</tr>
                			<tr>
                				<td class="tar">文章分类：</td>
                				<td>	 
									<select id="category_id" name="category_id" size="1" >
									<!--{if isset($category_array)}-->
										<!--{foreach from=$category_array item=cate}-->
											<option value="<!--{$cate.category_id}-->" <!--{if isset($article_array) && $article_array.article_category_id == $cate.category_id}-->selected<!--{/if}--> ><!--{$cate.category_title}--></option>
										<!--{/foreach}-->
									<!--{/if}-->
									</select>
									<font color="red">*</font>
				  			 	</td>
                			</tr>

                			<tr>
                				<td class="tar">外部链接：</td>
                				<td>	 
									<input type="text" id="article_link" name="article_link" maxlength="100" size="50" style="ime-mode:Disabled" autocomplete="off" value="<!--{$article_array.article_link|default:''}-->">
				  			 	</td>
                			</tr>
                			<tr>
                				<td class="tar">文章摘要：</td>
                				<td>	 
									<textarea rows="2" style="width:350px;" id="article_summary" name="article_summary" autocomplete="off"><!--{$article_array.article_summary|default:''}--></textarea>
				  			 	</td>
                			</tr>
                			<tr>
                				<td class="tar">使用状态：</td>
                				<td>
                                    <!--{if isset($article_array)}-->
                                        <input type="radio" name="useFlg" value="1" <!--{if $operFlg == 5 || $article_array.useFlg == 1}-->checked="checked"<!--{/if}-->>启用
                                        <input type="radio" name="useFlg" value="0" <!--{if $operFlg == 6 && $article_array.useFlg == 0}-->checked="checked"<!--{/if}-->>禁用
                                    <!--{else}-->
                                        <input type="radio" name="useFlg" value="1" checked="checked">启用
                                        <input type="radio" name="useFlg" value="0">禁用
                                    <!--{/if}-->

				  			 	</td>
                			</tr>
                		</tbody>
                	</table>
                	<div>
                        <textarea name="description" id="description" style="width:100%;height:400px;visibility:hidden;"><!--{$article_array.description|default:''}--></textarea>
                    </div>
                </form>
            </div>

        </div>
    </div>


    <div class="bottom_fixbox">
        <div class="rectbox tac">
            <input type="button" class="btn" onclick="article.check();" value="<!--{if $operFlg == 5}-->添加<!--{else}-->修改<!--{/if}-->文章" />&nbsp;&nbsp;&nbsp;
            <input type="button" class="btn" onclick="E.closeWindows();" value="关闭" />
        </div>
    </div>

    <!--{include file='comm/footer.tpl'}-->

</div>

<script type="text/javascript">

    window.editor = KindEditor.create("#description");

    var article = {

        article_id: <!--{$article_array.article_id|default:0}-->,

        //检查数据
        check: function() {
        	editor.sync();
            this.dt = E.getFormValues("article_form");
            var error_msg = "";
            if (this.dt.article_title == "")
                error_msg += "文章标题不能为空<br />";
			            	
            if (error_msg != "")
                E.alert(error_msg);
            else
                E.confirm("您确认要<!--{if $operFlg == 5}-->添加<!--{else}-->修改<!--{/if}-->文章信息吗？", "article.add");
        },
		
        //保存文章信息
        add: function() {
            $.ajax({
                type: "POST",
                url: "/invokingAjax-backend/content/article.ajax?operFlg=<!--{if $operFlg == 5}-->4<!--{else}-->5<!--{/if}-->",
                dataType: "JSON",
                data: this.dt,
                success: function( result_obj ) {
                    if (result_obj.code == 200) {
                        E.opener("article.load");
                        if (article.article_id == 0)
                            E.alert(result_obj.message, 2, "E.refresh");
                        else
                            E.alert(result_obj.message, 2, "E.closeWindows");
                    } else {
                        E.alert(result_obj.message);
                    }
                }
            });
        },

        //上传图片
        uploadPic:function(){
            E.open("/quanliadmin/app/uploads/articleImage.php", "上传", {height: 200,width: 800, top: 50, left: 150});
        },

        //回调显示图片
        showImage:function(imageUrl){
            $('#pic').attr('src', '/quanliadmin/docroot/images/article/' + imageUrl);
            $('#article_pic').val('/quanliadmin/docroot/images/article/' + imageUrl);
        }

    };
	

</script>

</body>

</html>